Generally, you delete the SpriteWindow, and then delete all the DIBs
that it used, including the background DIB. (These delete commands
delete the objects in memory, not the disk files!). You can call
DeleteSprite to delete a sprite, DeleteSpriteWindow to delete
a SpriteWindow, and DeleteDIB to delete a DIB.
If you deviate from this procedure, be careful: If you call
DeleteSpriteWindow, don't try afterwards to delete a sprite,
because DeleteSpriteWindow deletes all the sprites in that
SpriteWindow automatically. (This makes sense -- you can't
reassign the sprite to a new SpriteWindow. But you could use
the DIB in another window).
On the other hand, if you delete a sprite, you do still need to delete
any DIBs it used.
Consider the following situation: you drew up a musical note in a bitmap,
and made it into a bunch of sprites which all dance around the screen
at the same time. (You can do this, because you can create more than
one sprite from the same DIB). One of the notes is no longer wanted
so you call DeleteSprite. DeleteSprite deletes the DIB and all of
the other sprites suddenly have a big problem... This is why
DeleteSprite does not delete the DIB.
Chapter Six: What are the declare statements for this DLL?
const UPDATE_SCREEN = 1
const NO_UPDATE = 0
Declare Function CreateSpriteWindow Lib "VBSPRITE.DLL" (ByVal hWnd As Integer) As Long
Declare Sub DeleteSpriteWindow Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long)
Declare Function LoadDIB Lib "VBSPRITE.DLL" (ByVal filename As String) As Long
Declare Sub DeleteDIB Lib "VBSPRITE.DLL" (ByVal pDIB As Long)
Declare Sub SetBackground Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pDIB As Long, ByVal bUpdate As Integer)
Declare Function CreateSprite Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprDib As Long, ByVal initx As Integer, ByVal inity As Integer, ByVal initz As Integer, ByVal bRedraw As Integer) As Long
Declare Sub DeleteSprite Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprite As Long)
Declare Function SpriteHitTest Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal x As Integer, ByVal y As Integer) As Long
Declare Sub SetSpritePosition Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprite As Long, ByVal x As Integer, ByVal y As Integer, ByVal bUpdate As Integer)
Declare Sub SetSpriteZOrder Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprite As Long, ByVal z As Integer, ByVal bUpdate As Integer)
Declare Sub SetSpriteDIB Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprite As Long, ByVal pSprDib As Long, ByVal bUpdate As Integer)
Declare Function GetDIBWidth Lib "VBSPRITE.DLL" (ByVal pDIB As Long) As Long
Declare Function GetDIBHeight Lib "VBSPRITE.DLL" (ByVal pDIB As Long) As Long
Declare Sub RepaintSpriteWindow Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long)
Declare Sub SetSpriteVisible Lib "VBSPRITE.DLL" (ByVal pSpriteWnd As Long, ByVal pSprite As Long, ByVal bVisible As Integer, ByVal bUpdate As Integer)
Chapter Seven: Do You Have Any Sample Code?
Yes: SPRDEMO.MAK is a VB project that demonstrates use of VBSPRITE.DLL.
There are 3 sprites, and they all act differently to show off different
things. Nell (the girl) just sits there until you grab her with the
mouse and drag her around. The sun/moon sprite bounces off the bottom
of the screen. Every second or so, it changes from sun to moon, or
moon to sun, and it loses energy on each bounce. When you click it,
it gives it a boost and it starts bouncing higher. Finally, the duck
cycles rapidly through four bitmaps. When you click it, it falls down
to the bottom of the screen. That should show pretty well how a VB
program can control the behavior of sprites.
Chapter Eight: How Come This Can Only Be Used From VB?
Actually, anyone can use it.
Chapter Nine: What Do I Do if it Doesn't Work?
Send email to: a-wayner@microsoft.com.
This manual was written entirely using Microsoft(R) Notepad[tm].